/***************************************************************************
 *   Copyright (C) 2007 by Sassan Panahinejad (ico2)			   *
 *   ico2ico2@gmail.com							   *
 *                                                                         *
 *   This file is part of libaufs					   *
 *   Libaufs is free software; you can redistribute it and/or modify	   *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 3 of the License, or     *
 *   (at your option) any later version.				   *
 *									   *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of	   *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.			   *
 *									   *
 *   You should have received a copy of the GNU General Public License	   *
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 ***************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include "aufs.h"

/*
	This _example_ program creates a union at the location specified by the first argument.
	The remaining arguments become the branches.
*/
int main(int argc, char *argv[])
{
	int ret, i;
	set_output_level(3);	// turn debugging on
	if ( argc < 3 ) {
		printf("Not enough arguments\n");
		return 1;
	}
	ret = aufs_create_union(argv[1], argv[2], 1);
	if (ret) {
		printf("Creating union failed\n");
		return 2;
	}
	for (i=3; i < argc; i++) {
		ret = aufs_add_branch(argv[1], argv[i], 0, NULL);
		if (ret) {
			printf("Failed to add branch\n");
			return 2;
		}
	}
	return 0;
}
